package com.example.bootdemo2.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.bootdemo2.entity.User;
import com.example.bootdemo2.service.IUserService;
import com.example.bootdemo2.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lml
 * @since 2022-12-25
 */
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Resource
private IUserService service;
@GetMapping
public Result queryall(User user, Integer currentPage,Integer count){
    System.out.println(currentPage);
    System.out.println(count);

    return new Result(service.listBy(user,currentPage,count));
}
@PostMapping
    public Result SaveAndUpdata(User user){
    System.out.println(user);
    boolean b = service.saveOrUpdate(user);
    return new Result(b);
}
@DeleteMapping("{id}")
    public Result del(@PathVariable Integer id){
    boolean b = service.removeById(id);
    return new Result(b);
}
}

